{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from label_studio_sdk.client import LabelStudio"
   ]
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "ls = LabelStudio(\n",
    "    base_url='http://localhost:8080',\n",
    "    api_key='27c982caa9e599c9d81b25b00663e7d4f82c9e3c'\n",
    ")"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "e9df445f9d4a746c",
   "execution_count": null
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "project = ls.projects.create(\n",
    "    title='Live OCR',\n",
    "    description='A project to demonstrate live OCR with connected Tesseract model'\n",
    ")"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "71598abdbca596e2",
   "execution_count": null
  },
  {
   "cell_type": "markdown",
   "source": [
    "# Create ML backend server\n",
    "\n",
    "Go to the `examples/tesseract` directory and run the following command to start the ML backend server:\n",
    "```\n",
    "docker-compose up\n",
    "```\n",
    "\n",
    "It will create a server with Tesseract OCR model listening on `http://localhost:9090`."
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "a04744cba5e2a576"
  },
  {
   "cell_type": "markdown",
   "source": [
    "# Connect ML backend server to the project"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "45b8c6210f1df70d"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "ls.ml.create(\n",
    "    title='Tesseract OCR',\n",
    "    description='A model to perform OCR using Tesseract',\n",
    "    url='http://localhost:9090',\n",
    "    project=project.id,\n",
    "    is_interactive=True\n",
    ")"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "f9f90acea44fdf4e",
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
